<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="org.stbland.test.gillesjava.Pin"%>
<%@page import="org.stbland.test.gillesjava.PinType"%>
<%@page import="org.stbland.test.gillesjava.PinListGenerator"%>
<%@page import="org.stbland.test.gillesjava.PinDrawText"%>
<%@page import="org.stbland.test.gillesjava.PinDraw"%>
<%@page import="org.stbland.test.gillesjava.IntegratedCircuit"%>
<%
	IntegratedCircuit integratedCircuit = new IntegratedCircuit();

//	List<Pin> pinList = PinListGenerator.generate();
	PinListGenerator.generate(integratedCircuit.getPinList());

	int i = 10;
	Pin pin1 = new Pin();
	pin1.setType(PinType.OUTPUT);
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test de la classe Pin</title>
<script type="text/javascript">
	function draw() {
		var canvas = document.getElementById("canvas");
		var ctx = canvas.getContext("2d");

		// ctx.fillStyle = "rgb(200,0,0)";
		// ctx.fillRect(10, 10, 55, 50);

		// ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
		// ctx.fillRect(30, 30, 55, 50);
		<%
		int yOffset = 10;
		String color = null;
		for ( Pin pin : integratedCircuit.getPinList() ) {
			switch (pin.getType()) {
			case INPUT:
				color = "rgb(200,0,0)";
				%>
				console.log("pin INPUT");
				<%
				break;
			case OUTPUT:
				color = "rgb(0,0,200)";
				%>
				console.log("pin OUTPUT");
				<%
				break;
			case UNUSED:
				color = "rgb(100,100,100)";
				%>
				console.log("pin UNUSED");
				<%
				break;
			}
			%>
			ctx.fillStyle = "<%= color %>";
			 ctx.fillRect(30, <%=yOffset  %>, 250, 20);
			<%
			yOffset += 50;
		} /* end..for pinList */
		%>
		
	}
</script>
</head>
<body onload="draw()">
	<%="PinDrawText"%>
	<%
	PinDraw pinDraw = new PinDrawText(out);
	// pinDraw.draw(pinList);
	pinDraw.draw( integratedCircuit.getPinList() );
	%>
	


	<canvas id="canvas" width="300" height="300"></canvas>

</body>
</html>